package com.ruoyi.payInfo.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.payInfo.domain.PayInfo;
import com.ruoyi.payInfo.service.IPayInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * payInfoController
 * 
 * @author ruoyi
 * @date 2024-10-08
 */
@Controller
@CrossOrigin
@RequestMapping("/payInfo/payInfo")
public class PayInfoController extends BaseController
{
    private String prefix = "payInfo/payInfo";

    @Autowired
    private IPayInfoService payInfoService;

    @GetMapping()
    public String payInfo()
    {
        return prefix + "/payInfo";
    }

    /**
     * 查询payInfo列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestBody PayInfo payInfo)
    {
        startPage();
        List<PayInfo> list = payInfoService.selectPayInfoList(payInfo);
        return getDataTable(list);
    }

    /**
     * 导出payInfo列表
     */
    @Log(title = "payInfo", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PayInfo payInfo)
    {
        List<PayInfo> list = payInfoService.selectPayInfoList(payInfo);
        ExcelUtil<PayInfo> util = new ExcelUtil<PayInfo>(PayInfo.class);
        return util.exportExcel(list, "payInfo数据");
    }

    /**
     * 新增payInfo
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存payInfo
     */
    @Log(title = "payInfo", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PayInfo payInfo)
    {
        return toAjax(payInfoService.insertPayInfo(payInfo));
    }

    /**
     * 修改payInfo
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PayInfo payInfo = payInfoService.selectPayInfoById(id);
        mmap.put("payInfo", payInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存payInfo
     */
    @Log(title = "payInfo", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PayInfo payInfo)
    {
        return toAjax(payInfoService.updatePayInfo(payInfo));
    }

    /**
     * 删除payInfo
     */
    @Log(title = "payInfo", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(payInfoService.deletePayInfoByIds(ids));
    }
}
